<?php

namespace common\models\company;

use Yii;

/**
 * This is the model class for table "{{%company_department}}".
 *
 * @property int $id
 * @property int $parent_id 上级部门ID
 * @property string $name 部门名称
 * @property string $description 描述
 * @property string $found_date
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 * @property int $deleted_at 删除时间
 */
class CompanyDepartment extends \common\db\ActiveRecord {

    use \common\traits\Constants;

    const STATUS_DEFAULT = 0;
    const STATUS_ACTIVE = 10;

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%company_department}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['parent_id', 'status', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
            [['name', 'description'], 'required'],
            [['found_date'], 'safe'],
            [['name'], 'string', 'max' => 50],
            [['description'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'parent_id' => '上级部门ID',
            'name' => '部门名称',
            'description' => '描述',
            'found_date' => 'Found Date',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'deleted_at' => '删除时间',
        ];
    }

}
